from pydantic import BaseModel
from typing import Optional, Dict, Any
from datetime import datetime

# 系统设置基础模型
class SystemSettingBase(BaseModel):
    category: str
    key: str
    value: str
    data_type: Optional[str] = "string"
    description: Optional[str] = None

# 系统设置创建模型
class SystemSettingCreate(SystemSettingBase):
    pass

# 系统设置更新模型
class SystemSettingUpdate(BaseModel):
    value: Optional[str] = None
    description: Optional[str] = None
    is_active: Optional[bool] = None

# 系统设置响应模型
class SystemSettingResponse(SystemSettingBase):
    id: int
    is_active: bool
    created_at: datetime
    updated_at: datetime

    class Config:
        orm_mode = True

# 用户设置基础模型
class UserSettingBase(BaseModel):
    category: str
    settings: Dict[str, Any]

# 用户设置创建模型
class UserSettingCreate(UserSettingBase):
    pass

# 用户设置更新模型
class UserSettingUpdate(BaseModel):
    settings: Dict[str, Any]

# 用户设置响应模型
class UserSettingResponse(UserSettingBase):
    id: int
    user_id: int
    created_at: datetime
    updated_at: datetime

    class Config:
        orm_mode = True

# 批量设置模型
class SettingsBatch(BaseModel):
    system_settings: Optional[Dict[str, str]] = {}
    security_settings: Optional[Dict[str, str]] = {}
    notification_settings: Optional[Dict[str, bool]] = {}